home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2002 January / maximum-cd-2002-01.iso / Files / Mechwarrior 4 Mapping / MW4Editor.exe / content / ABLScripts / GenericScripts / Generic_Ambush.abl < prev    next >
Encoding:
Text File  |  2001-07-16  |  4.4 KB  |  156 lines

  1.  
  2. //------------------------------------------------------------------
  3. // NOTE: The fsm name below MUST be changed in order for the
  4. // script to be considered a unique entity!
  5.  
  6. fsm Generic_Ambush : integer;
  7.  
  8.  
  9. //------------------------------------------------------------------
  10.  
  11. // Generic_Ambush:
  12. //   Shuts down, waits until an enemy comes near, and then attacks.
  13.  
  14. //------------------------------------------------------------------
  15.  
  16.  
  17.  
  18. //------------------------------------------------------------------
  19. //     Constants
  20. //------------------------------------------------------------------
  21.  
  22.     const
  23.         #include_ <content\ABLScripts\mwconst.abi>
  24.  
  25. //------------------------------------------------------------------
  26. //     Types
  27. //------------------------------------------------------------------
  28.  
  29.     type
  30.         #include_ <content\ABLScripts\mwtype.abi>
  31.     
  32.  
  33. //------------------------------------------------------------------
  34. //     Variables
  35. //------------------------------------------------------------------
  36.  
  37.     var
  38.         static integer            attackRange;        // At what range do I start shooting?
  39.         static integer            withdrawRange;        // At what range do I withdraw from combat entirely?
  40.                                                                     
  41.         static integer            piloting;            // Piloting skill
  42.         static integer            gunnery;            // Gunnery skill/chance to hit
  43.         static real                minDelay;            // Minimum amount of time I will wait between shots once a weapon is reloaded
  44.         static real                maxDelay;            // Maximum amount of time I will wait between shots once a weapon is reloaded
  45.         static integer             eliteLevel;            // Elite level.  This helps determine tactics, defensive manuevers, opportunity fire
  46.                                                     // and other things.  It indicates a general level of combat experience.
  47.         static integer            attackThrottle;        // My attack throttle
  48.  
  49.          static integer            isShotRadius;        // How far away from me will I detect an enemy shot?
  50.  
  51.         static integer             attackSound;        // The attack sound I play when I first attack
  52.         static integer             deathSound;            // The sound I play when I die
  53.         
  54.         static integer            mood;                // My default mood.
  55.  
  56.         static integer            takeOffDistance;    // My take-off distance if I'm an airplane (ignored if not an airplane)
  57.  
  58. //------------------------------------------------------------------
  59. //     Init: my initialization function
  60. //------------------------------------------------------------------
  61.  
  62. function Init;
  63.     code
  64.         // script-specific variables
  65.         attackRange        = 500;
  66.         withdrawRange    = 2000;
  67.  
  68.         takeOffDistance    = 150;
  69.  
  70.         // driver settings
  71.         piloting        = 50;
  72.         gunnery            = 30;
  73.         minDelay        = 1.5;
  74.         maxDelay        = 3.0;
  75.         eliteLevel        = 30;
  76.         attackThrottle    = 80;
  77.         isShotRadius    = 120;
  78.         attackSound        = -1; // no sound
  79.         deathSound        = -1; // no sound
  80.         mood            = NEUTRAL_START;
  81.  
  82. endfunction;
  83.  
  84. //------------------------------------------------------------------
  85. //    StartState: my initial state
  86. //------------------------------------------------------------------
  87.  
  88. state StartState;
  89.  
  90.     code
  91.         SetFiringDelay            (ME,minDelay,maxDelay);
  92.         SetIgnoreFriendlyFire    (ME,true);
  93.         SetIsShotRadius            (ME,isShotRadius);
  94.         SetEntropyMood            (ME,mood);
  95.         SetCurMood                (ME,mood);
  96.         SetSkillLevel            (ME,piloting,gunnery,eliteLevel);
  97.         SetAttackThrottle        (ME,attackThrottle);
  98.                 
  99.         if (orderTakeOff(takeOffDistance) == true) then
  100.             trans WaitToAmbushState;
  101.         endif;
  102.  
  103. endstate;            
  104.  
  105. //------------------------------------------------------------------
  106. //    WaitInAmbushState: wait for someone to come close enough to attack
  107. //------------------------------------------------------------------
  108.  
  109. state WaitToAmbushState;
  110.     code
  111.         Shutdown(ME);
  112.  
  113.         if (FindEnemy(attackrange,FT_DEFAULT)) then
  114.             trans AttackState;
  115.         endif;
  116.  
  117. endstate;
  118.  
  119. //------------------------------------------------------------------
  120. //    AttackState: the ambush is over -- let's kick some ass!
  121. //------------------------------------------------------------------
  122.  
  123. state AttackState;
  124.     code
  125.         if (LeaveAttackState(withdrawRange)) then
  126.             trans WaitToAmbushState;
  127.         endif;
  128.  
  129.         if (attackSound <> -1) then    
  130.             PlaySoundOnce(attackSound);
  131.         endif;
  132.  
  133.         Startup(ME);
  134.  
  135.         OrderAttack(TRUE);
  136.  
  137. endstate;
  138.  
  139. //------------------------------------------------------------------
  140. //    DeadState: OK, I kicked the bucket.
  141. //------------------------------------------------------------------
  142.  
  143. state DeadState;
  144.     code
  145.         if (deathSound <> -1) then    
  146.             PlaySoundOnce(deathSound);
  147.         endif;        
  148.  
  149.         orderDie;
  150.  
  151. endstate;
  152.  
  153.  
  154. endfsm.
  155.  
  156.